package com.ebelter.btcomlib.views.dialogs.otherpick;

import android.content.Context;


import com.ebelter.btcomlib.R;
import com.ebelter.btcomlib.utils.StringUtils;
import com.ebelter.btcomlib.views.dialogs.picktime.BaseWheelPick;
import com.ebelter.btcomlib.views.dialogs.picktime.DatePickerHelper;

import com.ebelter.btcomlib.views.dialogs.picktime.OnChangeLisener;

import com.ebelter.btcomlib.views.dialogs.picktime.WheelView;

import java.util.Date;

public class TianCiPicker extends BaseWheelPick {

    private static final String TAG = "TianCiPicker";

    private WheelView yearView;


    private Integer[] yearArr;
    private DatePickerHelper datePicker;






    private OnChangeLisener onChangeLisener;
    private int selectDay;

    //选择时间回调
    public void setOnChangeLisener(OnChangeLisener onChangeLisener) {
        this.onChangeLisener = onChangeLisener;
    }

    public TianCiPicker(Context context) {
        super(context);

    }



    //初始化值
    public void init() {


        this.yearView = findViewById(R.id.year);
        yearArr = new Integer[]{1,2};
        setWheelListener(yearView, yearArr, false);
        //yearView.setCurrentItem(0);
    }


    public void setCurrentItem(int index){
        if (yearView!=null)yearView.setCurrentItem(index);
    }


    protected String[] convertData(WheelView wheelView, Integer[] data) {
        if (wheelView == yearView) {
            return new String[]{StringUtils.getResStr(R.string.tian),StringUtils.getResStr(R.string.ci)};
        }
        return new String[0];
    }

    @Override
    protected int getLayout() {
        return R.layout.tianci_wheel_picker;
    }

    @Override
    protected int getItemHeight() {
        return yearView.getItemHeight();
    }


    @Override
    protected void setData(Object[] datas) {
    }



    @Override
    public void onChanged(WheelView wheel, int oldValue, int newValue) {

        int year = yearArr[yearView.getCurrentItem()];


        if (onChangeLisener != null) {
            onChangeLisener.onChanged(null,yearView.getCurrentItem());
        }

    }

    @Override
    public void onScrollingStarted(WheelView wheel) {
    }

    @Override
    public void onScrollingFinished(WheelView wheel) {
    }


    //获取选中日期
    public int getSelectIndex() {

        int year = yearView.getCurrentItem();

        return year;

    }



}
